//
//  YGridView.h
//  yuimall_Iphone
//
//  Created by Gang.Wang on 12-4-26.
//  Copyright (c) 2012年 yuike. All rights reserved.
//

#import "UIViewEx.h"
#import "YTileLayer.h"
#import "CALayerEx.h"

@class YLayerDelegateProxy;
@protocol YGridViewDelegate;
@protocol YGridViewDelegateDataSource;

@interface YGridView : UIViewEx<UIGestureRecognizerDelegate>
{
    NSInteger tileRows;
    NSInteger tileColumns;
    NSInteger tileCount;
    
    CGFloat tileWidth;
    CGFloat tileHeight;
    CGFloat tileMargin;
    
    
        
    NSMutableArray * tileFrameEx;
    NSMutableArray * tileForFrameEx;
    
    YTileLayer    *heldTile;
    int      heldFrameIndex;
    CGPoint  heldStartPosition;
    CGPoint  touchStartLocation;
    
    YLayerDelegateProxy * proxy;
    id<YGridViewDelegate> delegate_;
    
    id<YGridViewDelegateDataSource> dataSource;
    
    BOOL bEdit;       
}

@property (nonatomic, assign) id <YGridViewDelegate> delegate;

@property (nonatomic, assign) id<YGridViewDelegateDataSource> dataSource;

@property (nonatomic, assign) NSInteger tileRows;
@property (nonatomic, assign) NSInteger tileColumns;
@property (nonatomic, assign) NSInteger tileCount;

@property (nonatomic, strong) NSMutableArray * tileFrameEx;
@property (nonatomic, strong) NSMutableArray * tileForFrameEx;

- (void) insterTileAtIndex:(YTileLayer *) tile index:(NSInteger) index;

- (void) removeTileWithIndex:(NSInteger) index;

- (void) setAllTileEditStatus:(BOOL) editing;

- (CGFloat) showNeedHeightByLastTile;

- (BOOL) isALLTileEditing;
@end


@protocol YGridViewDelegate <NSObject>
- (void) tileSequenceNumberChanged:(NSArray *) tiles;

- (void) clickWhichLayer:(CALayerEx*) layer;
- (void) willDeleteTile:(CALayerEx *) layer;

- (void) girdViewShowNeedHeight:(NSNumber *) showNeedHeight;

- (void) heldTileDidMoved:(NSValue *) pointValue;

@end

@protocol YGridViewDelegateDataSource <NSObject>
- (YTileLayer *) tileLayer:(YGridView *) gridView withTileIndex:(NSInteger) tileIndex;
@end









